# #有一个列表，["北京","上海","广东"]  1° 将中国所有省会城市添加到上述列表中  2° 广东称为第二大发达城市，将广东排在上海前面  3° [36710.36,35427.10,29863.23,29667.39,27665.36,27650.45,27620.38,25369.20]这是中国GDP排名前8的城市的GDP数值，请统计前8城市的GDP总和，平均GDP。
# A = ["北京","上海","广东","天津","长春","沈阳","呼和浩特","石家庄","乌鲁木齐","兰州","西宁","西安","银川","郑州","济南","太原","合肥","长沙","武汉","南京","成都","贵阳","昆明","南宁","拉萨","杭州","南昌","广州","福州","台北","海口","香港","澳门"]
# A[1] = "广东"
# A[2] = "上海"
# print("广东成为第二大发达城市后的列表为:",A)
#
# b = [36710.36,35427.10,29863.23,29667.39,27665.36,27650.45,27620.38,25369.20]
# GDP总和 = sum(b)
# 平均GDP = GDP总和 / 8
# print("GDP总和为:",GDP总和)
# print("平均GDP为:",平均GDP)





# #有以下一个列表，求其中是5的倍数的和
# a = [1,5,21,30,15,9,30,24]
# b = 0
# for i in a :
#     if i % 5 == 0 :
#         b += i
# print("列表中是5的倍数的和为:", b)






#有下列列表，请编程实现列表的数据翻转（京东金融的测试开发笔试题）
# list = [1,2,3,4,5,6,7,8,9]

# #方法一：列表对象的reverse()方法
# #语法：列表名.reverse()
# list.reverse()
# print("数据翻转结果为:list =",list)

# list2 = [1,2,3,4,5,6,7,8,9]
# #方法二：内置reversed()函数
# #语法：reversed(列表名)
# a = reversed(list2)   # 注意：此种方法使用时，列表名不能为python中函数的函数名，例如本题中的list，使用list函数后执行就会报错
# print("列表翻转结果（迭代对象）: list =", a)
# print("列表翻转结果转换成列表: list =", list(a))

# list = [1,2,3,4,5,6,7,8,9]
# #方法三：切片
# #语法：；列表名[x:y:z]
# # x:切片开始位置，默认为0
# # y:切片截至（但不包括）位置，默认为列表长度
# # z:切片的步长，默认为1；-1则表示从最后元素开始切片
# print("列表翻转结果：list = ", list[::-1])

# list = [1,2,3,4,5,6,7,8,9]
# #方法四：使用for循环
# a = list
# b = [a[len(a) - i - 1] for i in range(len(a))]
# print("列表翻转结果为: list = ", b)





# #请编程统计列表中的每个数字出现的次数（百度初级测试开发笔试题）
#
# #方法一：使用函数Counter,可以迅速获取list中每个元素出现的次数
# list = [1,4,7,5,8,2,1,3,4,5,9,7,6,1,10]
# from collections import Counter
# # arr = [1,4,7,5,8,2,1,3,4,5,9,7,6,1,10]
# # def counter(arr) :
# #     return Counter(arr)
# # print(counter(arr))
# arr = Counter(list)
# print(arr)

# #方法二：使用for循环
# list = [1,4,7,5,8,2,1,3,4,5,9,7,6,1,10]
# a = list
# b = {}
# for i in a :
#     if i not in b :
#         b[i] = 1
#     else :
#         b[i] += 1
# print(b)

# #方法三：利用list中的函数count，获取每个元素的出现次数
# a = [1,4,7,5,8,2,1,3,4,5,9,7,6,1,10]
# b = {}
# for i in a :
#     b[i] = a.count(i)
# print(b)

#方法四：利用Numpy索引，获取每个元素的出现次数













